<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Log extends CI_Log {
	var $logs = array();
	
    function MY_Log()
    {
        parent::CI_Log();		
    }	
	
	function write_log($level = 'error', $msg, $php_error = FALSE){
		parent::write_log($level, $msg, $php_error);
		
		//$memory	 = (!function_exists('memory_get_usage')) ? '0' : memory_get_usage();
		$b = load_class('Benchmark');
		$b->mark($msg);
		$this->logs[] = array(date('Y-m-d H:i:s P'), $level, $msg);
	}

	function writeMessage($type = 'done', $text = '')
	{
		$CI =& get_instance();
		$CI->load->library('auth');
		
		$user = $CI->auth->getUserData();
		$user['message']['text'] = $text;
		$user['message']['type'] = $type;
		$CI->auth->setUserData($user);
	}	
	
	function showMessage()
	{
		$CI =& get_instance();
		$CI->load->library('auth');
		
		$user = $CI->auth->getUserData();

		if (!empty($user['message']['text']))
		{
			echo '<p class="msg '.$user['message']['type'].'">'.$user['message']['text'].'</p>';	
		}
									
		$user['message']['text'] = '';
		$user['message']['type'] = '';
		$CI->auth->setUserData($user);
	}
	
}